﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;

namespace KlubSportowy.Filter
{
    public class FilterRolesAttribute : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase filterContext)
        {
            if(filterContext.Request.IsAuthenticated)
            return false;

           // string[] userRoles = Roles.GetEnumerator;
            foreach (string definedRole in this.Roles.Split(','))
            {

                
            }
            return true;
        }

        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            filterContext.Result = new RedirectToRouteResult(
                                       new RouteValueDictionary 
                                   {
                                       { "action", "Index" },
                                       { "controller", "Home" }
                                   });
        }
    }
}